#include "stdafx.h"
#include <boost/test/auto_unit_test.hpp>
#include "detail/bmock_in_arg_val.hpp"
#include "detail/bmock_test_control_tools.hpp"
#include <sstream>

namespace bmock {
	static const control_tools_ptr tl(new test_control_tools());
	static const char              name[]        = "arg";
	static const unsigned char     raw_mem_val[] = {0x01,0x02,0x03,0x04,0x05};
	static const std::string            x_val         = "0102030405";
	static const size_t            LEN           = sizeof(raw_mem_val);

	BOOST_AUTO_TEST_CASE(test_in_raw_mem_arg_val_print) {
		const arg_val_ptr p_val(make_in_arg_val(name,raw_mem(raw_mem_val,LEN)));
		const std::string      expected = "IN(\""+std::string(x_val)+"\")";
		std::ostringstream        os;

		BOOST_CHECK_NO_THROW(p_val->print(os));
		BOOST_CHECK_EQUAL(expected,os.str());
	}


	BOOST_AUTO_TEST_CASE(test_raw_mem_arg_val_validate) {
		const arg_val_ptr   p_val(make_in_arg_val(name,raw_mem(raw_mem_val,LEN)));
		const arg_val_str   expected(x_val,"");
		arg_checker         ac(tl);
		bool                result = true;

		ac.set_location(location(__FILE__,__LINE__+1));
		BOOST_CHECK_NO_THROW(result = p_val->validate(ac,expected));
		BOOST_CHECK(!result);
		BOOST_CHECK_EQUAL(expected,p_val->get_value(ac));
	}
}
